<?php

function view_sms($config,$param) {
    view_header_up($config,$param);
    //
    ?>
    <link  href="http://fonts.googleapis.com/css?family=Reenie+Beanie:regular" rel="stylesheet" type="text/css"> 
    <title>Idebeda-SMS</title>
    <?
    //
    view_header_bottom($config,$param);
    $off = isset($_GET['off']) ? ((intval($_GET['off']) > 0) ? intval($_GET['off']) : 1) : 1;
    ?>
    <h2>SMS Crew Idebeda</h2>
    <?php
    if (isset($_SESSION['addsucc'])) {
        echo '<div class="success alert">'.$_SESSION['addsucc'].'</div>';
        unset($_SESSION['addsucc']);
    }
    ?>
    <form action="" method="post" onsubmit="return validateForm(this)">
		<h3>Kirim SMS</h3>
		<div id="tambah-sms">
			<ul>
			<?php
				$db = new db($config);
				$dari = $_SESSION['logged']['id'];
				$orangs = $db->query("SELECT * FROM mn_crew WHERE 1 ORDER BY idCrew ASC");
				foreach ($orangs as $orang){
					$idc = $orang['idCrew'];
					$uname = $orang['username'];
					echo "<div style=\"float:left\"><input name=\"ckbox[]\" id=\"check$idc\" value=\"$idc\" type=\"checkbox\"><span></span> $uname </div>";
				}
				echo "<div style=\"clear:both\"></div>";
			?>
				<li class="field">
					<label class="inline" for="pesan">Isi Pesan</label>
					<textarea class="input textarea" rows="3" placeholder="isi pesan" name="pesan"></textarea>
				</li>
				<div class="medium primary btn"><input type="submit" name="sms" value="Kirim" /></div>
			</ul>
		</div>
	</form>
	<script type="text/javascript">
		function validateEmpty(fld) {
			var error = "";
		 
			if (fld.value.length == 0) {
				fld.style.background = 'Yellow'; 
				error = "1";
			} else {
				fld.style.background = 'White';
			}
			return error;  
		}
		function validateForm(theForm) {
			var reason = "";
			
			  reason += validateEmpty(theForm.pesan);
				  
			  if (reason != "") {
				alert("Perhatian, isi yang masih kosong.");
				return false;
			  }

			  return true;
			}
	</script>
<?
	view_footer($config,$param);
}
